<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<style type="text/css">
			#regdiv{
				width: 500px;
				height: 300px;
				background-color: #00FFFF;
			}
		</style>
	</head>
	<body>
		<div id='regdiv'>
			<h3 name='h3_name' align="center">用户注册</h3>
			用户名：<input type="" name="user" id="userid" value="" /><br />
			密 码：<input  type="password" name="pwd" id="pwdid" value="123456" /><br />
			性 别：<input type="radio" name="sex" id="" value="" />男
				<input type="radio" name="sex" id="" value="" />女<br />
			学 院：<select name="Xue">
				<option  value="">软件工程学院</option>
				<option value="">城乡建筑学院</option>
				<option value="">信息与制造学院</option>
				<option value="">医学护理学院</option>
			</select><br />
			爱 好：<input type="checkbox" name="hobby1" id="" value="" />篮球
				<input type="checkbox" name="hobby2" id="" value="" />排球
				<input type="checkbox" name="hobby3" id="" value="" />羽毛球
				<input type="checkbox" name="hobby4" id="" value="" />兵乒球<br />
				自我介绍：<textarea rows="6" cols="30" name="textarea_text"></textarea><br />
			<button type="button" onclick="Tiejiao();">提交</button>
			<button type="button" onclick="Checkname();">按name查找元素</button>
			<button type="button" onclick="Checktag();">按标签查找元素</button>
		</div>
	</body>
	<script type="text/javascript">
		function Checkname(){
			 console.log(document.getElementsByName('h3_name'));
			 console.log(document.getElementsByName('user'));
			 console.log(document.getElementsByName('pwd'));
			 console.log(document.getElementsByName('sex'));
			 console.log(document.getElementsByName('Xue'));
			 console.log(document.getElementsByName('hobby1'));
			 console.log(document.getElementsByName('hobby2'));
			 console.log(document.getElementsByName('hobby3'));
			 console.log(document.getElementsByName('hobby4'));
			 console.log(document.getElementsByName('textarea_text'));
		}
		function Checktag(){
			var ctag1=document.getElementsByTagName('select');
			var ctag2=document.getElementsByTagName('label');
			var ctag3=document.getElementsByTagName('input');
			var ctag4=document.getElementsByTagName('textarea');
			console.log(ctag1);
			console.log(ctag2);
			console.log(ctag3);
			console.log(ctag4);
		}
		function Tiejiao(){
			if(document.getElementById('userid').value == ''){
				alert('用户名为空')
			}
			if(document.getElementById('pwdid').value == '123456' || document.getElementById('pwdid').value == ''){
				alert('密码未更改或密码为空')
			}
		}
	</script>
</html>
